package com.moxie.ocr.ocr.utils;

import android.content.Context;
import android.util.Log;
import android.view.Display;
import android.view.WindowManager;



public class MXScreenUtils {

    public static final String TAG = "MXScreenUtils";

    public static int sScreenWidth;
    public static int sScreenHeight;
    public static float sScreenDensityDpi;

    public static void initialize(Context context) {
        Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        sScreenWidth = display.getWidth();
        sScreenHeight = display.getHeight();
        sScreenDensityDpi = context.getResources().getDisplayMetrics().densityDpi;
        MXLog.i(TAG, "sScreenWidth", sScreenWidth);
        MXLog.i(TAG, "sScreenHeight", sScreenHeight);
        MXLog.i(TAG, "sScreenDensityDpi", sScreenDensityDpi);
    }

    public static int dip2px(float dpValue) {
        return (int) (dpValue * (sScreenDensityDpi / 160));
    }

    public static float px2dip(int px) {
        return px * 160 / sScreenDensityDpi;
    }

}
